package com.cssw.fyzb.wap.service;

import com.cssw.fyzb.base.web.domain.AjaxData;
import com.cssw.fyzb.wap.model.vo.*;
import com.ydn.appserver.MinaAppClient;
import com.ydn.appserver.Request;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * @author
 */
@Service
public class QuickPayService extends BaseService {

    @Autowired
    private MinaAppClient busiClient;

    @Autowired
    private MinaAppClient tpsClient;

    public AjaxData<UserQuickSignVo> getQuickSign(Long userId) {
        Request request = new Request("GetQuickSign");
        request.setParameter("userId", userId);
        return convertData(busiClient.send(request), UserQuickSignVo.class);
    }

    public AjaxData<QuickSignResultVo> quickSign(Long userId, String bankCode, String bankName, String cardNo, String mobile, String userName, String idCard) {
        Request request = new Request("QuickSign");
        request.setParameter("userId", userId);
        request.setParameter("bankCode", bankCode);
        request.setParameter("bankName", bankName);
        request.setParameter("cardNo", cardNo);
        request.setParameter("mobile", mobile);
        request.setParameter("userName", userName);
        request.setParameter("idCard", idCard);
        return convertData(busiClient.send(request), QuickSignResultVo.class);
    }

    public AjaxData<QuickSignSmsResultVo> quickSignSmsOk(Long userId, String orderNo, String verifyCode) {
        Request request = new Request("QuickSignSmsOk");
        request.setParameter("userId", userId);
        request.setParameter("orderNo", orderNo);
        request.setParameter("verifyCode", verifyCode);
        return convertData(busiClient.send(request), QuickSignSmsResultVo.class);
    }

    public AjaxData queryQuickSignOrder(Long userId, String orderNo) {
        Request request = new Request("QuickSignQuery");
        request.setParameter("userId", userId);
        request.setParameter("orderNo", orderNo);
        return convertData(busiClient.send(request));
    }

    public AjaxData<QuickPayResultVo> quickPay(Long userId, String quickId, String busiType, String extendData) {
        Request request = new Request("QuickPay");
        request.setParameter("userId", userId);
        request.setParameter("quickId", quickId);
        request.setParameter("busiType", busiType);
        request.setParameter("extendData", extendData);
        return convertData(busiClient.send(request), QuickPayResultVo.class);
    }

    public AjaxData<QuickPaySmsResultVo> quickPaySmsOk(Long userId, String orderNo, String verifyCode) {
        Request request = new Request("QuickPaySmsOk");
        request.setParameter("userId", userId);
        request.setParameter("orderNo", orderNo);
        request.setParameter("verifyCode", verifyCode);
        return convertData(busiClient.send(request), QuickPaySmsResultVo.class);
    }

    public AjaxData queryQuickPayOrder(Long userId, String orderNo) {
        Request request = new Request("QuickPayQuery");
        request.setParameter("userId", userId);
        request.setParameter("orderNo", orderNo);
        return convertData(busiClient.send(request));
    }
}
